furny.furndb.importer
Class DBModelSource

java.lang.Object
  extended by furny.furndb.importer.DBModelSource
All Implemented Interfaces:
IModelSource

public class DBModelSource
extends java.lang.Object
implements IModelSource

Implementation of a model source, that iterates over all furnitures in the FurnDB.

Since:
26.06.2011
Author:
stephan

Field Summary
private  java.util.List<java.lang.Long> ids
           
private  int index
           
private static java.util.logging.Logger LOGGER
           
 
Constructor Summary
DBModelSource()
          Creates a model source, that iterates over all furnitures in the FurnDB.
 
Method Summary
 int getSize()
          Returns the number of elements.
 boolean hasNext()
          Method to check if more elements are there.
 Furniture next()
          Gets the next element.
 Furniture next(int offset)
          This methods works like next(), but allows to skip elements.
 Furniture previous()
          Gets the previous element.
 void reset()
          Resets and starts at the first element.
 void seek(Furniture furn)
          Seeks the given furniture and remembers its position.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOGGER

private static final java.util.logging.Logger LOGGER

ids

private java.util.List<java.lang.Long> ids

index

private int index
Constructor Detail

DBModelSource

public DBModelSource()
Creates a model source, that iterates over all furnitures in the FurnDB.

Since:
26.06.2011
Method Detail

reset

public void reset()
Description copied from interface: IModelSource
Resets and starts at the first element.

Specified by:
reset in interface IModelSource

seek

public void seek(Furniture furn)
Description copied from interface: IModelSource
Seeks the given furniture and remembers its position. A call to next() will give the element after the seeked element.

Specified by:
seek in interface IModelSource
Parameters:
furn - The furniture to seek

hasNext

public boolean hasNext()
Description copied from interface: IModelSource
Method to check if more elements are there.

Specified by:
hasNext in interface IModelSource
Returns:
more elements are left

next

public Furniture next(int offset)
Description copied from interface: IModelSource
This methods works like next(), but allows to skip elements. If the offset is negative, it will return previous elements.

The method works circular, when hasNext() returns false, and the last element is reached, a call to next() will start at the first element.

Specified by:
next in interface IModelSource
Parameters:
offset - The offset of elements
Returns:
the furniture at the desired position

next

public Furniture next()
Description copied from interface: IModelSource
Gets the next element. It simply calls next(1).

Specified by:
next in interface IModelSource
Returns:
the next furniture

previous

public Furniture previous()
Description copied from interface: IModelSource
Gets the previous element. It simply calls next(-1).

Specified by:
previous in interface IModelSource
Returns:
the previous furniture.

getSize

public int getSize()
Description copied from interface: IModelSource
Returns the number of elements.

Specified by:
getSize in interface IModelSource
Returns:
the number of elements.